Page({
  data: {
    longitude: 116.397428,
    latitude: 39.90923,
    markers: []
  },
  onLoad() {
    console.log('车辆列表页加载');
    this.getCurrentLocation();
  },
  getCurrentLocation() {
    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        const { latitude, longitude } = res;
        this.setData({
          latitude,
          longitude,
          markers: [{
            id: 1,
            latitude,
            longitude,
            width: 32,
            height: 32
          }]
        });
      },
      fail: () => {
        wx.showToast({
          title: '获取位置失败',
          icon: 'none'
        });
      }
    });
  },
  refreshLocation() {
    this.getCurrentLocation();
    wx.showToast({
      title: '位置已更新',
      icon: 'success'
    });
  }
});